<!--app/views/pages/_link_examples.html.erb-->
<h2>link_to 方法示例</h2>

<h3>1. 基本用法</h3>
<p><%= link_to "首页", root_path %></p>
<p><%= link_to "关于页面", about_page_path %></p>
<p><%= link_to "联系页面", contact_page_path %></p>
<p><%= link_to "时间页面", time_page_path %></p>

<h3>2. 带参数的链接</h3>
<p><%= link_to "用户详情", user_path(1) %></p>
<p><%= link_to "微博详情", micropost_path(1) %></p>
<p><%= link_to "编辑微博", edit_micropost_path(1) %></p>
<p><%= link_to "删除微博", micropost_path(1), method: :delete, data: { confirm: "确定要删除吗？" } %></p>
<p><%= link_to "书籍详情", book_path(1) %></p>
<p><%= link_to "编辑书籍", edit_book_path(1) %></p>

<h3>3. 带选项的链接</h3>
<p><%= link_to "新窗口打开", "https://www.google.com", target: "_blank" %></p>
<p><%= link_to "带CSS类", about_page_path, class: "btn btn-primary" %></p>
<p><%= link_to "带ID", contact_page_path, id: "contact-link" %></p>
<p><%= link_to "带样式", time_page_path, style: "color: red; font-weight: bold;" %></p>
<p><%= link_to "禁用状态", "#", class: "disabled", onclick: "return false;" %></p>

<h3>4. 块形式链接</h3>
<%= link_to root_path do %>
  <span class="icon">🏠</span>
  <span class="text">返回首页</span>
<% end %>

<%= link_to about_page_path, class: "block-link" do %>
  <h4>关于我们</h4>
  <p>了解更多关于我们的信息</p>
<% end %>

<%= link_to contact_page_path do %>
  <div style="border: 1px solid #ccc; padding: 10px; margin: 10px 0;">
    <h4>联系我们</h4>
    <p>点击这里联系我们</p>
  </div>
<% end %>

<h3>5. 邮件链接</h3>
<p><%= link_to "发送邮件", "mailto:contact@example.com" %></p>
<p><%= link_to "带主题的邮件", "mailto:contact@example.com?subject=问题咨询" %></p>
<p><%= link_to "带主题和内容的邮件", "mailto:contact@example.com?subject=问题咨询&body=您好，我有一个问题..." %></p>

<h3>6. 外部链接</h3>
<p><%= link_to "Google", "https://www.google.com", target: "_blank", rel: "noopener" %></p>
<p><%= link_to "GitHub", "https://github.com", target: "_blank", rel: "noopener noreferrer" %></p>
<p><%= link_to "Rails官网", "https://rubyonrails.org", target: "_blank" %></p>
<p><%= link_to "Ruby官网", "https://www.ruby-lang.org", target: "_blank" %></p>

<h3>7. 条件链接</h3>
<% if @current_hour < 12 %>
  <p><%= link_to "上午好！", "#", class: "greeting" %></p>
<% else %>
  <p><%= link_to "下午好！", "#", class: "greeting" %></p>
<% end %>

<% if @is_weekend %>
  <p><%= link_to "周末愉快！", "#", class: "weekend" %></p>
<% else %>
  <p><%= link_to "工作日加油！", "#", class: "workday" %></p>
<% end %>

<h3>8. 带图标的链接</h3>
<p><%= link_to "📧 联系我们", contact_page_path %></p>
<p><%= link_to "⏰ 当前时间", time_page_path %></p>
<p><%= link_to "ℹ️ 关于我们", about_page_path %></p>
<p><%= link_to "🏠 返回首页", root_path %></p>

<h3>9. 集合路由链接</h3>
<p><%= link_to "热门微博", hot_microposts_path %></p>
<p><%= link_to "最新微博", recent_microposts_path %></p>
<p><%= link_to "流行微博", popular_microposts_path %></p>

<h3>10. 成员路由链接</h3>
<p><%= link_to "点赞微博", like_micropost_path(1) %></p>

